package com.charging.serviceImpl;

import com.charging.bean.Advertisement;
import com.charging.bean.Site;
import com.charging.bean.layuiBean.ResultPage;
import com.charging.bean.layuiBean.VoPage;
import com.charging.mapper.AdvertisementMapper;
import com.charging.service.AdvertisementService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 小程序广告 服务实现类
 * </p>
 *
 * @author 冯政尚
 * @since 2019-09-20
 */
@Service
public class AdvertisementServiceImpl extends ServiceImpl<AdvertisementMapper, Advertisement> implements AdvertisementService {


    /**
     * @param voPage
     * @return 后台查询
     */
    @Override
    public ResultPage<Advertisement> selectMyPage(VoPage voPage) {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("page", (voPage.getPage() - 1) * voPage.getLimit());
        paramMap.put("limit", voPage.getLimit());
        List<Advertisement> list = baseMapper.selectMyPage(paramMap);
        Integer count = baseMapper.countMyPage(paramMap);
        ResultPage<Advertisement> resultPage = new ResultPage<>();
        resultPage.setCode(0);
        resultPage.setCount(count);
        resultPage.setMsg("成功");
        resultPage.setData(list);
        return resultPage;
    }

    /**
     * @return 小程序查询
     */
    @Override
    public List<Advertisement> selectList() {
        return baseMapper.selectList();
    }

}
